package com.nwpu.coursesupport.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.nwpu.coursesupport.criteria.ForumModuleSearchCriteria;
import com.nwpu.coursesupport.entity.bean.JSONResult;
import com.nwpu.coursesupport.service.imple.ForumService;

@Controller
@RequestMapping("/forum")
public class ForumController extends AbstractController{
	
	@Autowired
	private ForumService forumService;
	
	@RequestMapping("/list")
	public String list(@RequestParam("courseId")Integer courseId,Integer pageNO, HttpServletRequest request){
		JSONResult rst = new JSONResult();
		//rst.fail();
		
		ForumModuleSearchCriteria fMLSearchCriteria = new ForumModuleSearchCriteria();
		fMLSearchCriteria.setCourseId(courseId);
		fMLSearchCriteria.setPageNo(pageNO==null? 1:pageNO);
		rst = forumService.listForum(fMLSearchCriteria);
		//rst.success();
		request.setAttribute("data", this.parseData(rst));
		
		return "/teapage/Forum-index";
	}
}
